﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StorySmith;
using NUnit.Framework;
using System.IO;

namespace StorySmithTests.StorySmithStory
{
    public class StorySmithStory:IStory
    {

        #region IStory Members

        public string AsA
        {
            get
            {
                return "StorySmith user";
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string IWantTo
        {
            get
            {
                return "use Story,Given,When,Then behavior extensions ";
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string SoThat
        {
            get
            {
               return "I can apply BDD";
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion
    }
    
    [TestFixture]
    public class when_the_extension_method_for_is_called
    {
        StorySmithStory story_smith_story;
        StringWriter sw;

        [SetUp]
        public void GivenAStory()
        {
            
            story_smith_story=new StorySmithStory();
            Behavior.For(story_smith_story).Given(" StorySmith.Behavior.For extension method ");
        }

        [Test]
        public void should_display_the_defined_story ()
        {
            sw = new System.IO.StringWriter();
            TextWriter oldTw = Console.Out;
            Console.SetOut(sw);
            Behavior.For(story_smith_story);
            string consoleOutput = sw.ToString();
            Console.SetOut(oldTw);
            Behavior.Should(()=>Assert.That(consoleOutput.Contains("StorySmith"),
                                "actual string:'" +consoleOutput + "' -DOES NOT CONTAIN- 'story smith'") );
            
        }
    }
}
